import java.util.Scanner;

public class Main2 {
    public static int getMaxSubLen(String a, String b) {
        char[] str1 = a.toCharArray();
        char[] str2 = b.toCharArray();

        int maxLen = 0;
        int[][] maxSubLen = new int[str1.length + 1][str2.length + 1];
        for (int i = 1; i <= str1.length; i++) {
            for (int j = 1; j <= str2.length; j++) {
                //如果第i个字符和第j个字符相等,则进行累加
                if (str1[i - 1] == str2[j - 1]) {
                    maxSubLen[i][j] = maxSubLen[i - 1][j - 1] + 1;
                    if (maxLen < maxSubLen[i][j]) {
                        maxLen = maxSubLen[i][j];
                    }
                }
            }
        }
        return maxLen;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String str1 = scanner.next();
        String str2 = scanner.next();
        if (str1.length() < str2.length()) {
            System.out.println(getMaxSubLen(str1, str2));
        } else {
            System.out.println(getMaxSubLen(str2, str1));
        }
    }
}
